Problem Note 62726: The IS8601_CONVERT call routine calculates an incorrect duration
The IS8601_CONVERT call routine converts an ISO 8601 interval to datetime and duration values, or converts datetime and duration values to an ISO 8601 interval. When the IS8601_CONVERT call routine computes a duration from two SAS datetime values, the computation might not be correct when the dates are not in consecutive months. The computation is correct when dates are in consecutive months.
The sample code on the Full Code tab illustrates the problem.
There is currently no circumvention for this issue.
Operating System and Release Information
SAS System | Base SAS | Linux | 9.2 TS1M0 | 9.4 TS1M6 |
Linux for x64 | 9.2 TS1M0 | 9.4 TS1M6 |
OpenVMS on HP Integrity | 9.2 TS1M0 | 9.4 TS1M6 |
Solaris for x64 | 9.2 TS1M0 | 9.4 TS1M6 |
HP-UX IPF | 9.2 TS1M0 | 9.4 TS1M6 |
64-bit Enabled Solaris | 9.2 TS1M0 | 9.4 TS1M6 |
64-bit Enabled HP-UX | 9.2 TS1M0 | 9.4 TS1M6 |
64-bit Enabled AIX | 9.2 TS1M0 | 9.4 TS1M6 |
Windows Vista for x64 | 9.2 TS1M0 | |
Windows Vista | 9.2 TS1M0 | |
Microsoft Windows XP Professional | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Standard Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.2 TS1M0 | |
Microsoft® Windows® for x64 | 9.2 TS1M0 | 9.4 TS1M6 |
Microsoft Windows XP 64-bit Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.2 TS1M0 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.2 TS1M0 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.2 TS1M0 | |
z/OS 64-bit | 9.2 TS1M0 | 9.4 TS1M6 |
z/OS | 9.2 TS1M0 | 9.4 TS1M6 |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
The IS8601_CONVERT call routine can convert two SAS datetime values to a duration. The Start and End variables represent date values. Since we need SAS datetime values for the IS8601_CONVERT call routine parameters, Start and End values are read with the E8601DNw. informat to create SAS datetime values. An explanation of the parameters to the call routine follows:
- The 'dt/dt' notation indicates that two datetime values are being supplied.
- A duration is requested in the second argument.
- The name of the first datetime variable.
- The name of the second datetime variable.
- Name of the new variable containing the resulting duration.
The duration value that is calculated is not in a readable format, so it needs to be formatted with the $N8601E format. The PUT statement writes the value to the SAS log.
data _null_;
length _aedur $32.;
start = '2017-10-04';
startn = input(start,E8601DN. );
end = '2017-12-01';
endn = input(end,E8601DN. );
CALL IS8601_CONVERT( 'dt/dt', 'du', startn, endn , _aedur);
_aedur = put(_aedur,$N8601E.);
put _aedur;
run;
The incorrect computed value is P1M28D.
The correct value should be P1M27D.
Type: | Problem Note |
Priority: | high |
Topic: | SAS Reference ==> CALL routines ==> IS8601_CONVERT
|
Date Modified: | 2018-08-10 14:22:33 |
Date Created: | 2018-08-08 11:14:38 |